package com.consts;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.StrUtil;

import java.nio.charset.Charset;
import java.util.HashMap;

/**
 * @ClassName GenerateConsts
 * @Description TODO
 * @Author 谭庆伟
 * @Date 2020/9/8 11:00
 * @Version 1.0
 **/
@SuppressWarnings("ALL")
public class GenerateConsts {

    public static final StrBuilder ROUTERMAPJSNEXTBUILDER = new StrBuilder();
    public static final StrBuilder VUECONFIGJSNEXTBUILDER = new StrBuilder();

    public static void writeAllConfigJs(String templatePath,String vuePath){
        String templetaPath = templatePath + "vueConfigJs" + ".txt";
        String templetaStr = FileUtil.readUtf8String(templetaPath);
        HashMap<String, Object> map = new HashMap<>();
        map.put("configNext", VUECONFIGJSNEXTBUILDER.toString());
        String format = StrUtil.format(templetaStr, map);
        FileUtil.writeString(format, vuePath+"\\src\\router\\config.js",Charset.defaultCharset());
        //VUECONFIGJSNEXTBUILDER.clear();
    }
    public static void writeAllRouterMapJs(String templatePath,String vuePath){
        ROUTERMAPJSNEXTBUILDER.clear();
        String templetaPath = templatePath + "routerMapJs" + ".txt";
        String templetaStr = FileUtil.readUtf8String(templetaPath);
        HashMap<String, Object> map = new HashMap<>();
        map.put("routerMapJsNext", ROUTERMAPJSNEXTBUILDER.toString());
        String format = StrUtil.format(templetaStr, map);
        //GenerateConsts.BUILDER.append(format);
        FileUtil.writeString(format, vuePath+"\\src\\router\\router.map.js",Charset.defaultCharset());

    }

}
